package com.model;

import java.util.Date;
import java.util.HashMap;

public class LeaveModel extends HashMap<String, String> {
	private static final long serialVersionUID = -8053305746875602186L;

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public LeaveModel(String id, String username, String leavetypename,
			String natureofleave, String startdate, String enddate,
			String reason, String comment, int totalDay, String status) {
		super();
		put("id", id);
		put("username", "Username : "
				+ (username.isEmpty() ? "No Username" : username));
		put("leavetypename", "Leave Type : "
				+ (leavetypename.isEmpty() ? "No Leave Type" : leavetypename));
		put("natureofleave", "Nature of Leave : "
				+ (natureofleave.isEmpty() ? "No Nature Of Leave"
						: natureofleave));
		put("startdate", "Start Date : "
				+ (startdate.isEmpty() ? "No Start Date" : startdate));
		put("enddate", "End Date : "
				+ (enddate.isEmpty() ? "No End Date" : enddate));
		if (!startdate.isEmpty() && !enddate.isEmpty()) {
			put("leavedate", "Leave Date : " + startdate + " to " + enddate);

			put("totalday", "Total Leave Day : " + totalDay);
		}
		put("reason", "Reason : " + (reason.isEmpty() ? "No Reason" : reason));
		put("comment", status.equalsIgnoreCase("rejected") ? "Comment : "
				+ (comment.isEmpty() || comment == null ? "No Comment"
						: comment) : "");
		put("status", "Status : " + (status.isEmpty() ? "No Status" : status));
	}

	public String toDetail() {
		String detail = "";
		if (!this.containsKey("leavedate")) {
			detail = this.get("username") + "\n" + this.get("leavetypename")
					+ "\n" + this.get("natureofleave") + "\n"
					+ this.get("startdate") + "\n" + this.get("enddate") + "\n"
					+ this.get("reason") + "\n" + this.get("status") + "\n"
					+ this.get("comment");
		} else {
			detail = this.get("username") + "\n" + this.get("leavetypename")
					+ "\n" + this.get("natureofleave") + "\n"
					+ this.get("leavedate") + "\n" + this.get("totalday")
					+ "\n" + this.get("reason") + "\n" + this.get("status")
					+ "\n" + this.get("comment");
		}
		return detail;
	}
	
	public LeaveModel() {
		super();
	}
}
